package com.wxp.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.wxp.dao.DaoSupport;
import com.wxp.service.StatisticsService;
import com.wxp.util.IData;

@Service
public class StatisticsServiceImpl implements StatisticsService {

	@Resource(name = "daoSupport")
	private DaoSupport dao;

	@SuppressWarnings("unchecked")
	@Override
	public List<IData> fetchSummary(IData param) throws Exception {
		return (List<IData>) dao.findForList("StatisticsMapper.fetchSummary", param);
	}
	
	@SuppressWarnings("unchecked")
	@Override
	public List<IData> fetchSummaryFever(IData param) throws Exception {
		return (List<IData>) dao.findForList("StatisticsMapper.fetchSummaryFever", param);
	}
	
	@SuppressWarnings("unchecked")
	@Override
	public List<IData> fetchStatisticswc(IData param) throws Exception {
		return (List<IData>) dao.findForList("StatisticsMapper.wc", param);
	}
	@SuppressWarnings("unchecked")
	@Override
	public List<IData> fetchStatisticshh(IData param) throws Exception {
		return (List<IData>) dao.findForList("StatisticsMapper.hh", param);
	}
	@SuppressWarnings("unchecked")
	@Override
	public List<IData> fetchStatisticsfg(IData param) throws Exception {
		return (List<IData>) dao.findForList("StatisticsMapper.fg", param);
	}
	@SuppressWarnings("unchecked")
	@Override
	public List<IData> fetchWorkTrend(IData param) throws Exception {
		return (List<IData>) dao.findForList("StatisticsMapper.fetchWorkTrend", param);
	}
	
	@SuppressWarnings("unchecked")
	@Override
	public List<IData> fetchReport(IData param) throws Exception {
		return (List<IData>) dao.findForList("StatisticsMapper.fetchReport", param);
	}
	
	@SuppressWarnings("unchecked")
	@Override
	public List<IData> fetchOutReturnWork(IData param) throws Exception {
		return (List<IData>) dao.findForList("StatisticsMapper.fetchOutReturnWork", param);
	}
	
	@SuppressWarnings("unchecked")
	@Override
	public List<IData> fetchYqqs(IData param) throws Exception {
		return (List<IData>) dao.findForList("StatisticsMapper.fetchYqqs", param);
	}
	
	@SuppressWarnings("unchecked")
	@Override
	public List<IData> getPxInfo(IData param) throws Exception {
		List<IData> iDataList = (List<IData>) dao.findForList("StatisticsMapper.getPxInfo", param);
		if(iDataList.size()==0) {
			iDataList = (List<IData>) dao.findForList("StatisticsMapper.getYesPxInfo", param);
		}
		
		if(iDataList.size()>0) {
			IData iData =  new IData();
			
			int pzrs = 0;
			int brzjrs = 0;
			int brjsrs = 0;
			
			for(IData i:iDataList){
				pzrs += Integer.parseInt((String)i.get("todayNum"));
				brzjrs += Integer.parseInt((String)i.get("incNum"));
				brjsrs += Integer.parseInt((String)i.get("decNum"));
			}
			
			iData.put("client", "合计");
			iData.put("trainPro", "");
			iData.put("startDate", "");
			iData.put("endDate", "");
			iData.put("todayNum", pzrs);
			iData.put("incNum", brzjrs);
			iData.put("decNum", brjsrs);
			iDataList.add(iData);
		}
		return iDataList;
	}
	
	@SuppressWarnings("unchecked")
	@Override
	public List<IData> mapdata(IData param) throws Exception {
		return (List<IData>) dao.findForList("StatisticsMapper.mapdata", param);
	}

}
